package com.mingyuan.library.infra.lending.patron.entity;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.Instant;
import java.util.UUID;

/**
 * 预定数据库实体
 * @author yangzk
 * @date 2023/12/28 19:49
 **/
@NoArgsConstructor(access = AccessLevel.PACKAGE)
@Getter
public class HoldDatabaseEntity {

    Long id;
    UUID patronId;
    UUID bookId;
    UUID libraryBranchId;
    Instant till;

    HoldDatabaseEntity(UUID bookId, UUID patronId, UUID libraryBranchId, Instant till) {
        this.bookId = bookId;
        this.patronId = patronId;
        this.libraryBranchId = libraryBranchId;
        this.till = till;
    }
    /**
     * 在指定图书馆分馆中读者是否预定指定图书
     * @author yangzk
     * @param patronId 读者ID
     * @param bookId 图书ID
     * @param libraryBranchId 图书馆分馆ID
     * @date 2023/12/28 19:49
     **/
    boolean is(UUID patronId, UUID bookId, UUID libraryBranchId) {
        return  this.patronId.equals(patronId) &&
                this.bookId.equals(bookId) &&
                this.libraryBranchId.equals(libraryBranchId);
    }

}
